﻿namespace IpRange;

class Program
{
    static async Task Main(string[] args)
    {
        ParseIpCidr ipCidr = new ParseIpCidr();
        await ipCidr.Parse("ipv4.json", "ipv4.txt");

        NetworkLatencyTester tester = new("ip.txt", "report.csv");
        tester.OnProgressed += async (ip, latency) =>
        {
            await Console.Out.WriteLineAsync($"[{DateTime.Now:HH:mm:ss}] {ip} 平均延迟: {latency}ms");
        };

        tester.OnCompleted += async report =>
        {
            await Console.Out.WriteLineAsync(
                $"[{DateTime.Now:HH:mm:ss}] 测试完成，总共 {report.Count} 条记录, 报告保存路径: {Environment.CurrentDirectory}");
        };
        await tester.RunTestAsync();
    }
}